<?php 
namespace app\common\model;
class MemberCard extends Common{
	protected $insert = ['addtime'=>SYS_TIME];
	public function save_datas($data){
		$count = $this->where('userid', $data['userid'])->count();
		$datas = [
			'userid' => $data['userid'],
			'cardno' => $data['cardno'],
			'cardname' => $data['cardname'],
			'cardtype' => $data['cardtype'],
			'province' => $data['province'],
			'city' => $data['city'],
			'address' => $data['address'],
			'phone' => $data['phone'],
		];
		if (!$count) {
			return $this->insert($datas);
		}else{
			return $this->where('userid', $data['userid'])->update($datas);
		}
	}
}